//
//  DisCoveryViewController.m
//  EasyChat
//
//  Created by dllo on 16/6/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "DiscoveryViewController.h"
#import "DiscoveryTableViewCell.h"
#import "StepCountViewController.h"
#import "SZQRCodeViewController.h"
#import "GaodeMapViewController.h"
#import "QRViewController.h"

@interface DiscoveryViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,retain)UITableView *myTableView;


@end

@implementation DiscoveryViewController

-(void)dealloc{

    [super dealloc];
    [_myTableView release];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"朋友圈";
    
    //修改导航栏标题的颜色 和 大小
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],
                                                                     
                                                                     NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //创建tableview
    [self createTableView];
    
    
    
}

-(void)createTableView{

    self.myTableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.myTableView.backgroundColor = [UIColor colorWithRed:245 / 255.0 green:245 / 255.0 blue:245 / 255.0 alpha:1.0];
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    
    self.myTableView.dataSource = self;
    self.myTableView.delegate = self;
    
    [self.myTableView registerClass:[DiscoveryTableViewCell class] forCellReuseIdentifier:@"reuse"];



}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 2;


}

//分区数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{


    return 2;
}

//cell 高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 50;

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    DiscoveryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.rightImageV.image = [UIImage imageNamed:@"jiantou"];
    
    if (indexPath.section == 0 && indexPath.row == 0) {
        cell.midLabel.text = @"计步器";
        cell.leftImageV.image = [UIImage imageNamed:@"picture0"];
        
    }
   
    if (indexPath.section == 0 && indexPath.row == 1) {
        cell.midLabel.text = @"地图";
        cell.leftImageV.image = [UIImage imageNamed:@"picture1"];
        
    }
    if (indexPath.section == 1 && indexPath.row == 0) {
        cell.midLabel.text = @"扫一扫";
        cell.leftImageV.image = [UIImage imageNamed:@"picture2"];
        
    }
    if (indexPath.section == 1 && indexPath.row == 1){
    
    cell.midLabel.text = @"二维码";
        cell.leftImageV.image = [UIImage imageNamed:@"picture3"];
    
    }
    
    return cell;



}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    if (section > 0) {
        return 20;
    } else {
        return 10;
    }


}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 0 && indexPath.row == 0) {
        StepCountViewController *StepVC = [[StepCountViewController alloc] init];
        [self.navigationController pushViewController:StepVC animated:YES];
    }if (indexPath.section == 1 && indexPath.row == 0) {
        SZQRCodeViewController *SZQRVC = [[SZQRCodeViewController alloc] init];
        [self.navigationController pushViewController:SZQRVC animated:YES];
    }if (indexPath.section == 0 && indexPath.row == 1)
    {
        GaodeMapViewController *mapVC = [[GaodeMapViewController alloc] init];
        [self.navigationController pushViewController:mapVC animated:YES];
    }if(indexPath.section == 1 && indexPath.row == 1){
        QRViewController *qr = [[QRViewController alloc] init];
        [self.navigationController pushViewController:qr animated:YES];
    }


}
// 不隐藏tabBar
- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
